{extend name="public/base"/}
{block name="style"}
<link href="__PUBLIC__/ieasy/css/recently.css?v=2.1.49" rel="stylesheet" type="text/css">
<link href="__PUBLIC__/ieasy/css/classify.css?v=2.1.49" rel="stylesheet" type="text/css">
{/block}
{block name="body"}
<div id="console_main"></div>
<div class="head_tit_box">
	<a href="javascript:;" class="head_return_page_but"></a>
		<div class="head_menu_but_box">
		<a href="javascript:;" class="head_menu_but"></a>
	</div>
		<h1> 小说精选 </h1>
</div>
<!--导航-->
{block name="include"}{include file="public:dropnav" /}{/block}
<div class="body_sytle">
	<div class="c_list_box">
		<ul class="r_img_ul">
		</ul>
		<div class="loading_box"><span>正在加载中，请稍后......</span></div> 
		<!--r_img_ul 列表 r_img_remove_select-->
	</div>
	
	<div class="content_null_box" style="display: none; padding-top: 1rem;">
		<img src="__PUBLIC__/ieasy/img/icon_16.png" style="width: 1.28rem;" />
		<span>暂无该类别图书，换个条件试试看吧！</span>
		<div class="content_null_but_box">
			<a href="/">去首页看看</a>
		</div>
	</div>
</div>

{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.min.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.cookie.min.js?v=2.1.49"></script>

<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.picLazyLoad.min.js?v=2.1.49"></script>

<script type="text/javascript" src="__PUBLIC__/ieasy/js/common.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/cps_log.js?v=2.1.49"></script>
<script type="text/javascript">
var sBookstop=true,sBookstopTime=null;
var channel = {$channel};
var start=0, 
limit=10,
sBookstop=true, 
sBookstopTime=null, 
pagesize=10;

$(function(){
	loadingList();
	
	$(window).scroll(function(){
		var nWinH =  document.documentElement.clientHeight;
		var nScrollTop = (document.body.scrollTop || document.documentElement.scrollTop) + nWinH;
		var nBodyScrollH = document.body.scrollHeight;
		if(sBookstop && nBodyScrollH - nScrollTop < 240){
			bookstoptime();
			$('.loading_box').html('<span>正在加載中，请稍候......</span>').show();
			loadingList();
		}
	});
});

function loadingList(){
	$.ajax({
		type: 'get',
		url: '/api/index/ranking/',
		timeout: 10000,
		cache: false,
		dataType: 'json',
		data: {
			'start': start,
        	'limit': limit,
			'type': 6,
        	'channel':channel,
		},
		success: function (data) {
			clearTimeout(sBookstopTime);
			if (typeof data == 'string') {
				data = JSON.parse(data);
			}
			if(data.code==2){
			   $('.c_list_box,.loading_box').hide();
			   $('.content_null_box').show();
				return false;
			}
			var sLi = '';
			for(var i=0; i<data.length; i++){
					
					sLi += '<li>\
						<a href="/book/info/id/'+ data[i]['id'] +'">\
							<div class="r_img">\
								<img src="'+ data[i]['cover'] +'" data-original="'+ data[i]['cover'] +'" onerror="this.src=\'/public/novel/images/default.jpg \'"/>\
							</div>\
							<div class="r_img_text">\
								<h3>'+ data[i]['title'] +'</h3>\
								<p>'+ data[i]['intro'] +'</p>\
								<div class="r_img_other">\
									<i>'+ data[i]['author'] +'</i>\
									<strong>'+ data[i]['allvisit'] +'人在追</strong>\
								</div>\
							</div>\
						</a>\
					</li>';

				
			}
			$('.r_img_ul').append(sLi);
			start+=pagesize;
			if(data.length < pagesize){
				$('.loading_box').html('<span>已显示全部</span>').show();
				sBookstop = false;
			}else{
				$('.loading_box').html('<span>下拉加载更多</span>').show();
				sBookstop = true;
			}			
			$('img').picLazyLoad({
				effect : "fadeIn"
			});

		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}



//防止重复请求数据
function bookstoptime() {
	clearTimeout(sBookstopTime);
	sBookstop = false;
	sBookstopTime = setTimeout(function () {
		sBookstop = true;
	}, 10000);
}

</script>
{/block}